export const commandMapMixin = {
  data() {
    return {
      map: null
    }
  },
  computed: {
    layerMap() {
      return this.map.getMap()
    }
  },
  mounted() {
    this.map = this.$refs.map.map
    this.layerMap.on('pointermove', this.pointerMove)
  },
  methods: {
    /**
    * @Description 鼠标点击地图
    * @Date 2019/11/18 15:08
    * @Author yuesheng.zhu@topevery.club
    */
    handleLayerMapClick(event) {
      console.log('地图鼠标点击', event)
    },
    /**
    * @Description 监听地图鼠标移动事件
    * @Date 2019/11/18 15:04
    * @Author yuesheng.zhu@topevery.club
    */
    pointerMove(event) {
      const feature = this.map.getClickFeature(event)
      if (feature === undefined) {
        this.layerMap.getTargetElement().style.cursor = 'auto'
      } else {
        this.layerMap.getTargetElement().style.cursor = 'pointer'
      }
    }
  }
}
